//
//  MarcoHeader.h
//  JinYong_iOS_Store
//
//  Created by 王厚一 on 2017/10/17.
//  Copyright © 2017年 why. All rights reserved.
//

#ifndef MarcoHeader_h
#define MarcoHeader_h




//显示提示
#define kShowError(str)                         [ShowMessageTool showMessage:kApplication andStr:str];
#define kShowSuccess(str)                       [ShowMessageTool showSucess:kApplication andStr:str];
#define kShowText(str)                          [ShowMessageTool MBShowText:str andShowView:self.view andDelay:1.0];

//主窗口
#define kApplication                            [UIApplication sharedApplication].keyWindow
//版本号
#define kOSVersion                              [[[UIDevice currentDevice] systemVersion] floatValue]

//尺寸
#define SCREENBounds                [UIScreen mainScreen].bounds
#define SCREENWidth                 CGRectGetWidth(SCREENBounds)
#define SCREENHeight                CGRectGetHeight(SCREENBounds)
//屏幕宽/高
#define SCREENW [UIScreen mainScreen].bounds.size.width
#define SCREENH [UIScreen mainScreen].bounds.size.height

//字体
#define FontX(CGFloat)              [UIFont systemFontOfSize:CGFloat]
#define BIGFontX(CGFloat)           [UIFont boldSystemFontOfSize:CGFloat]

//颜色
#define RGBA(r,g,b,a)               [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b)                  RGBA(r,g,b, 1.0f)

//宽高
#define viewH(view1) view1.frame.size.height
#define viewW(view1) view1.frame.size.width
#define viewX(view1) view1.frame.origin.x
#define viewY(view1) view1.frame.origin.y

//是否为iOS7
#define iOS7 ([[UIDevice currentDevice].systemVersion doubleValue] >= 7.0)
//是否为iOS8及以上系统
#define iOS8 ([[UIDevice currentDevice].systemVersion doubleValue] >= 8.0)


//根据像素计算对应的宽度，适合任意屏幕
#define ActualW(w) [UIScreen mainScreen].bounds.size.width*w/375
//根据像素计算对应的高度，适合任意屏幕
#define ActualH(h) [UIScreen mainScreen].bounds.size.height*(h)/667
// 屏幕 宽高 比(设置字体大小用)
#define RATE (SCREENW) / 750
// 设置不同大小字体
#define MARGIN40 RATE*40
#define MARGIN30 RATE*30
#define MARGIN29 RATE*29
#define MARGIN28 RATE*28
#define MARGIN27 RATE*27
#define MARGIN26 RATE*26
#define MARGIN25 RATE*25
#define MARGIN20 RATE*20

#define FONTSIZE(font) RATE*font * 2

//weakself
#define WeakObj(o) autoreleasepool{} __weak typeof(o) o##Weak = o;


//比较字符串
#define StringisNil(string)         string == nil || string.length == 0 ? YES:NO
#define StringNotNil(string)        string == nil || string.length == 0 ? NO:YES

//发通知
#define sendNotification(key)                 [[NSNotificationCenter defaultCenter] postNotificationName:key object:self userInfo:nil];
#define sendValueNotification(key)(value)          [[NSNotificationCenter defaultCenter] postNotificationName:key object:self userInfo:value];
#define removeNotification(key)                 [[NSNotificationCenter defaultCenter]removeObserver:self name:key object:nil];

//单例
#define DEF_SINGLETON( ... ) \
+ (instancetype)sharedInstance;

#define IMP_SINGLETON( ... ) \
+ (instancetype)sharedInstance \
{ \
static dispatch_once_t once; \
static id __singleton__; \
dispatch_once( &once, ^{ __singleton__ = [[self alloc] init]; } ); \
return __singleton__; \
}


#endif /* MarcoHeader_h */
